import pymysql
import datetime

if __name__ == "__main__":
    conn = pymysql.connect(
        host="127.0.0.1",
        user="haojg",
        password="haojg",
        database="stocks",
        charset="utf8",
    )

    cursor = conn.cursor()

    query_sql = """
    select 
    sd_date,sd_date_time,sd_code,sd_symbol,sd_name,       
    sd_open,sd_high,sd_low,sd_close,sd_volume,        
    sd_amount,sd_adjust_flag,sd_data_type,create_time,update_time 
    from 
    t_stock_k_minute_data tskmd 
    """
    try:
        cursor.execute(query_sql)

        # 获取所有查询到的结果
        ret1 = cursor.fetchall()
        print(ret1)

        conn.commit()
    except Exception as e:
        print("error = ", e)
        conn.rollback()

    cursor.close()
    conn.close()

    print("end ok")
